Skip to content

docs: document manual CMake build and ctest workflow for C++ tests#19387

Open
AswaniSahoo wants to merge 3 commits intopytorch:mainfrom
AswaniSahoo:docathon/contributing-cpp-tests
Open

docs: document manual CMake build and ctest workflow for C++ tests#19387
AswaniSahoo wants to merge 3 commits intopytorch:mainfrom
AswaniSahoo:docathon/contributing-cpp-tests

Conversation

@AswaniSahoo
Copy link
Copy Markdown
Contributor

Summary

Adds documentation to the Testing section of CONTRIBUTING.md showing how to build C++ tests manually with CMake and run individual tests using ctest. This covers a practical workflow that is useful for attaching a debugger, running a single test in isolation, and keeping a build directory around for quick rebuild cycles.

The CMake invocation and flags are consistent with what test/run_oss_cpp_tests.sh already uses internally.

Fixes #11979

Test plan

  • Content is accurate — CMake flags match test/run_oss_cpp_tests.sh
  • Only modifies the "Running Tests Locally" section; no other sections changed
  • Docs build succeeds (sphinx-build -b html docs/source docs/_build/html)
  • git diff --check passes (no trailing whitespace)

cc @GregoryComer @AlannaBurke @mergennachin

Copilot AI review requested due to automatic review settings May 8, 2026 02:03
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 8, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19387

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 11 Awaiting Approval, 1 New Failure

As of commit 2ff32a3 with merge base a49171d (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds contributor documentation for a manual CMake-based workflow to build and run ExecuTorch C++ tests locally, complementing the existing test/run_oss_cpp_tests.sh helper and enabling more iterative workflows (e.g., keeping a persistent build dir, running a single test via ctest).

Changes:

  • Document a manual CMake configure/build/install flow for C++ tests under cmake-out.
  • Document using ctest to list tests and run tests by regex from the build directory.
  • Add brief guidance on extending the configuration with additional -DEXECUTORCH_BUILD_* options as needed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CONTRIBUTING.md
Comment on lines +324 to +336
To build C++ tests manually with CMake, run the following from the repository root:

```bash
cmake . -Bcmake-out -DCMAKE_INSTALL_PREFIX=cmake-out -DEXECUTORCH_BUILD_TESTS=ON
cmake --build cmake-out -j9 --target install
```

You can then use `ctest` to list or run individual C++ tests directly:

```bash
ctest --test-dir cmake-out -N
ctest --test-dir cmake-out -R <test_name_regex> --output-on-failure
```
@AswaniSahoo
Copy link
Copy Markdown
Contributor Author

@pytorchbot label "release notes: none"

@pytorch-bot pytorch-bot Bot added the release notes: none Do not include this in the release notes label May 8, 2026
Copilot AI review requested due to automatic review settings May 9, 2026 07:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread CONTRIBUTING.md

```bash
ctest --test-dir cmake-out -N
ctest --test-dir cmake-out -R <test_name_regex> --output-on-failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve documentation on running cpp tests in CONTRIBUTING.md

4 participants